package model

import "time"

type Category struct {
	CategoryID   int64     `json:"categoryId" gorm:"column:category_id;primary_key;auto_increment" binding:"-"`
	CategoryName string    `json:"categoryName" gorm:"column:category_name;not null;default:''" binding:"required"`
	Icon         string    `json:"icon" gorm:"column:icon;not null;default:''" binding:"required"`
	CreateDate   time.Time `json:"-" gorm:"column:create_time;not null;autoCreateTime"`
	Videos       []Video   `json:"-" gorm:"many2many:category_video;foreignKey:CategoryID;joinForeignKey:category_id;references:VideoID;joinReferences:video_id"`
}

func (Category) TableName() string {
	return "category"
}

type CategoryQuery struct {
	Page       int   `json:"page" form:"page" valid:"required~页码不能为空"`               // 页码
	PageSize   int   `json:"pageSize" form:"pageSize" valid:"required~页数不能为空"`       // 每页大小
	CategoryID int64 `json:"categoryId" form:"categoryId" valid:"required~分类id不能为空"` //分类id
}
